using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace Integrator.DAL
{
    public class CentraProduct
    {
        public string connString = "Server=localhost;Database=Integrator;User ID=sa;Password=sa;Connection Reset=FALSE;Min Pool Size=2;Connection Lifetime=120;Connection Timeout=60;";
        public string MaSP= string.Empty;
        public string TenSP= string.Empty;
        public string ChiNhanh= string.Empty;
        public string POS= string.Empty;
        public string TaiSanDamBao= string.Empty;
        public string ApDungDNghiep= string.Empty;
        public string LoaiLaiSuat= string.Empty;
        public string DinhKyTinhLai= string.Empty;
        public string ApDung0PhanTram= string.Empty;
        public string TinhLaiSauDaoHan= string.Empty;
        public string DuGocTinhLai= string.Empty;
        public string HinhThucGiaiNgan= string.Empty;
        public string ThuTruocKhoanPhaiTra= string.Empty;
        public string TachKhoanVay= string.Empty;
        public string VayBoSung= string.Empty;
        public string NhapKhoanVay= string.Empty;
        public string GocCoDinh= string.Empty;

        public void Save()
        {
            SqlConnection conn = new SqlConnection(connString);
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[tblSanPhamTW]([MaSP], [TenSP],[ChiNhanh],[POS],[TaiSanDamBao],[ApDungDNghiep],[LoaiLaiSuat],[DinhKyTinhLai],[ApDung0%],[TinhLaiSauDaoHan],[DuGocTinhLai],[HinhThucGiaiNgan],[ThuTruocKhoanPhaiTra],[TachKhoanVay],[VayBoSung],[NhapKhoanVay],[GocCoDinh])VALUES(@MaSP, @TenSP,@ChiNhanh,@POS,@TaiSanDamBao,@ApDungDNghiep,@LoaiLaiSuat,@DinhKyTinhLai,@ApDung0PhanTram,@TinhLaiSauDaoHan,@DuGocTinhLai,@HinhThucGiaiNgan,@ThuTruocKhoanPhaiTra,@TachKhoanVay,@VayBoSung,@NhapKhoanVay,@GocCoDinh)", conn);
                cmd.Parameters.AddWithValue("@MaSP", MaSP);
                cmd.Parameters.AddWithValue("@TenSP", TenSP);
                cmd.Parameters.AddWithValue("@ChiNhanh", ChiNhanh);
                cmd.Parameters.AddWithValue("@POS", POS);
                cmd.Parameters.AddWithValue("@TaiSanDamBao", TaiSanDamBao);
                cmd.Parameters.AddWithValue("@ApDungDNghiep", ApDungDNghiep);
                cmd.Parameters.AddWithValue("@LoaiLaiSuat", LoaiLaiSuat);
                cmd.Parameters.AddWithValue("@DinhKyTinhLai", DinhKyTinhLai);
                cmd.Parameters.AddWithValue("@ApDung0PhanTram", ApDung0PhanTram);
                cmd.Parameters.AddWithValue("@TinhLaiSauDaoHan", TinhLaiSauDaoHan);
                cmd.Parameters.AddWithValue("@DuGocTinhLai", DuGocTinhLai);
                cmd.Parameters.AddWithValue("@HinhThucGiaiNgan", HinhThucGiaiNgan);
                cmd.Parameters.AddWithValue("@ThuTruocKhoanPhaiTra", ThuTruocKhoanPhaiTra);
                cmd.Parameters.AddWithValue("@TachKhoanVay", TachKhoanVay);
                cmd.Parameters.AddWithValue("@VayBoSung", VayBoSung);
                cmd.Parameters.AddWithValue("@NhapKhoanVay", NhapKhoanVay);
                cmd.Parameters.AddWithValue("@GocCoDinh", GocCoDinh);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
    }
}
